package org.shoukaiseki.aqoeous.utils;

import java.util.List;

/**
 * 来源: org.springframework.util.StringUtils
 * org.shoukaiseki.aqoeous.utils.StringUtils
 * <br>
 *
 * @author shoukaiseki ブログ http://www.shoukaiseki.top/<br> E-メール jiang28555@Gmail.com<br>
 * @date 2020-12-17 08:40:39<br>
 */
public class AqoeousUtils {


//    public static void validAggregatedQueryColumnList(List<String> aggregatedQueryColumnList){
//        if (aggregatedQueryColumnList==null||aggregatedQueryColumnList.isEmpty()) {
//            throw new RuntimeException("aggregatedQueryColumnList 不能为null或者空");
//        }
//    }


    public static String capitalize(String str) {
        return changeFirstCharacterCase(str, true);
    }

    /**
     * 首字母小写
     * @param str
     * @return
     */
    public static String unCapitalize(String str) {
        return changeFirstCharacterCase(str, false);
    }

    private static String changeFirstCharacterCase(String str, boolean capitalize) {
        if (!hasLength(str)) {
            return str;
        } else {
            char baseChar = str.charAt(0);
            char updatedChar;
            if (capitalize) {
                updatedChar = Character.toUpperCase(baseChar);
            } else {
                updatedChar = Character.toLowerCase(baseChar);
            }

            if (baseChar == updatedChar) {
                return str;
            } else {
                char[] chars = str.toCharArray();
                chars[0] = updatedChar;
                return new String(chars, 0, chars.length);
            }
        }
    }

    public static boolean hasLength( String str) {
        return str != null && !str.isEmpty();
    }
}
